/// @tags: Binary
#include <cstdio>
#include <iostream>

using std::cin, std::cout;

namespace BlueQuantum {

constexpr int maxn = 1e3 + 1;

int find_kth(int a[], int n, int b[], int m, int k) {
  if (n == 0) return b[k - 1];
  if (m == 0) return a[k - 1];
  if (k == 1) return a[0] <= b[0] ? a[0] : b[0];
  if (a[k / 2 - 1] <= b[k / 2 - 1]) {
    return find_kth(a + k / 2, n - (k / 2), b, m, k - (k / 2));
  } else {
    return find_kth(a, n, b + k / 2, m - (k / 2), k - (k / 2));
  }
}

int main() {
  int n, m;
  int a[maxn], b[maxn];
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  if (((n + m) & 1) == 0) {
    cout << (find_kth(a, n, b, m, (n + m) / 2) + find_kth(a, n, b, m, (n + m) / 2 + 1)) / 2.0;
  } else {
    cout << find_kth(a, n, b, m, (n + m) / 2 + 1);
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("leetcode_4.in", "r", stdin);
  freopen("leetcode_4.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
